package com.geline.wordtool.config;

import com.geline.wordtool.handler.MysqlTableInfoHandler;
import com.geline.wordtool.handler.TableInfoHandler;
import com.geline.wordtool.service.WordDocService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * 自动装配
 *
 * @author: mx
 * @date: 2024-12-04 09:46
 */
@Slf4j
public class WordToolAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public TableInfoHandler initTableInfoHandler(JdbcTemplate jdbcTemplate) {
        log.info("...... init MysqlTableInfoHandler ......");
        return new MysqlTableInfoHandler(jdbcTemplate);
    }

    @Bean
    @ConditionalOnMissingBean
    public WordDocService initWordDocService(TableInfoHandler handler) {
        log.info("...... init WordDocService ......");
        return new WordDocService(handler);
    }
}
